﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Abreu.Profile.ObjectClasses;
using Abreu.Profile.Database;

namespace Abreu.Profile.Classes
{
    public class Application
    {
        #region Class Members
        CorpAbreuDataContext _corpAbreuDC = new CorpAbreuDataContext();
        #endregion

        /// <summary>
        /// Gets the info of a application using applicationId
        /// </summary>
        /// <param name="applicationId"></param>
        /// <returns>ApplicationInfo struct</returns>
        public ApplicationInfo GetApplicationInfo(int applicationId)
        {
            ApplicationInfo applicationInfo = null;

            //Get Application Info with P_ApplicationInfo_Sel
            var objApplicationItem = _corpAbreuDC.P_GetApplicationInfo(applicationId);

            foreach (P_GetApplicationInfoResult resObjApplicationItem in objApplicationItem)
            {
                applicationInfo = new ApplicationInfo(resObjApplicationItem.ApplicationId, resObjApplicationItem.SystemId, resObjApplicationItem.PrecedentAplicationId,
                                                resObjApplicationItem.LanguageId, resObjApplicationItem.Name, resObjApplicationItem.ApplicationDescription,
                                                resObjApplicationItem.LevelApplication, resObjApplicationItem.IsAutoManagement, resObjApplicationItem.StatusApplication);
            }

            //Returns Application Info
            return applicationInfo;
        }
    }
}
